package com.ibeetl.admin.console.service;


import com.ibeetl.admin.console.dao.FiFinItemCheckDetailjgDao;
import com.ibeetl.admin.console.entity.FiFinItemCheckDetailjg;


import com.ibeetl.admin.console.web.dto.JGHZExcelImportData;
import com.ibeetl.admin.core.service.CoreBaseService;
import com.ibeetl.admin.core.util.PlatformException;
import org.beetl.sql.core.engine.PageQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;






/**
 * FiFinItemCheckDetailjg Service
 */

@Service
@Transactional
public class FiFinItemCheckDetailjgService extends CoreBaseService<FiFinItemCheckDetailjg>{

    @Autowired
    private FiFinItemCheckDetailjgDao fiFinItemCheckDetailjgDao;

    public PageQuery<FiFinItemCheckDetailjg>queryByCondition(PageQuery query){
        PageQuery ret =  fiFinItemCheckDetailjgDao.queryByCondition(query);
        queryListAfter(ret.getList());
        return ret;
    }

    public void batchDelFiFinItemCheckDetailjg(List<Long> ids){
        try {
            fiFinItemCheckDetailjgDao.batchDelFiFinItemCheckDetailjgByIds(ids);
        } catch (Exception e) {
            throw new PlatformException("批量删除FiFinItemCheckDetailjg失败", e);
        }
    }
    public List<JGHZExcelImportData> queryExcel(PageQuery<FiFinItemCheckDetailjg> query) {
        PageQuery<FiFinItemCheckDetailjg> ret = fiFinItemCheckDetailjgDao.queryByCondition(query);
        List<FiFinItemCheckDetailjg> list = ret.getList();
        List<JGHZExcelImportData> items = new ArrayList<>();
        for(FiFinItemCheckDetailjg user:list) {
            JGHZExcelImportData userItem = new JGHZExcelImportData();
            userItem.setManageCom(user.getManageCom());
            userItem.setCodename(user.getName());
            userItem.setBuType(user.getCodeName());
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            String time= sdf.format(user.getAccountDate());
            userItem.setAccountDate(time);
            userItem.setcActuCount(user.getCActuCount());
            userItem.setcActuMoney(user.getCActuMoney());
            userItem.setfCount(user.getFCount());
            userItem.setfMoney(user.getFMoney());
            userItem.setDifCount(user.getDifCount());
            userItem.setDifMoney(user.getDifMoney());
//            CoreDict dict = dictService.findCoreDict(CoreDictType.USER_STATE,user.getState());
//            userItem.setStateText(dict.getName());
//
//            if(StringUtils.isNotEmpty(user.getJobType1())){
//                dict = dictService.findCoreDict("job_type",user.getJobType1());
//                userItem.setJobType1Text(dict.getName());
//            }
//
//            String orgName = orgRoot.findChild(user.getOrgId()).getName();
//            userItem.setOrgText(orgName);
            items.add(userItem);

        }
        return items;

    }
}